<template>
  <view class="">
    <view class="" v-if="estimate">
      <view class="without" v-if="withoutjl">
        <view class="">
          <image class="recordimg" src="https://www.iwangbang.com/skin/wx_mp_aixz/record.png" mode=""></image>
        </view>
        没有记录
      </view>
      <view  v-for="(item,index) in userlist" :key="index">
        <view class="box">
          <view class="header-box" >
            <view class="headerimg-box">
              <image class="headerimg" :src="item.headimg == null ? 'https://www.iwangbang.com/skin/wx_mp_aixz/initial.png' : item.headimg" mode=""></image>
            </view>
            <view class="" >
              <view class="" style="margin-top: 5rpx;font-size: 32rpx;">用户名:&nbsp;{{item.username}}</view> 
              <view class="" style="color: #ccc;margin-top: 10rpx;font-size: 26rpx;">{{item.regtime == undefined ? '' : '注册时间:&nbsp;' + item.regtime}}</view>
                <view class="" style="color: #ccc;margin-top: 10rpx;" v-if="item.addtime == undefined ? false : true">{{item.addtime == undefined ? '' : '下单时间:&nbsp;' + item.addtime}}</view>
            </view>
          </view>
          <view class="" style="line-height: 100rpx;display: flex;">   
            <view v-if="item.xfprice == undefined ? false : true" style="margin: 0 2rpx;">{{item.xfprice == '' ? '0' : '共消费'+item.xfprice+'元' }}</view>
            <view v-if="item.price == undefined ? false : true"  class="">共消费{{item.price}}元</view>
          </view>
        </view>
      </view>
    </view>
    <view class="" v-else>
      <scroll-view class="dialogue-box" :scroll-y="true"  :scroll-top="scrollTop" style="">
        <uni-table border stripe emptyText="暂无更多数据" >
        	<!-- 表头行 -->
        	<uni-tr>
            <uni-th width="150"  align="">用户名</uni-th>
              <uni-th  width="80" align="">返点</uni-th>
        		<uni-th width="150" align="">时间</uni-th>
        	
        	</uni-tr>
        	<!-- 表格数据行 -->
        	<uni-tr v-for="(item) in yjlist" :key="item.id">
            <uni-td>{{item.remarks }}</uni-td>
        		<uni-td>{{item.price}}</uni-td>
            <uni-td>{{item.addtime }}</uni-td>
        	</uni-tr>
        </uni-table>
      </scroll-view>
    </view>
  </view>
</template>

<script>
  export default {
    onLoad(e) {
      console.log(e);
      this.userid = e.id
    },
    onShow() {
      this.getuserlist()
    },
    data() {
      return {
        yjlist:[],
        userlist:'',
        userid:'',
        estimate:true,
        scrollTop:0,
        withoutjl:false
      }
    },
    methods:{
      getuserlist() {
        uni.request({
        	url: getApp().globalData.apiDomain+'/invite/inviteDetail',
        	method: 'POST',
        	header: {
        		'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
        		'token': uni.getStorageSync('wbyun_token'),
            'wbapp':'weixin_mp_xbgy'
        	},
        	data: {},
        	dataType: 'json',
        	success:  res => {
            console.log(res);
        		if (res['data']['code'] == 200) {
              if(this.userid == '直推用户') {
                  this.userlist = res.data.datas.yiji
                  if(this.userlist.length == 0) {
                    this.withoutjl = true
                  }
                  uni.setNavigationBarTitle({
                    title:'直推用户'
                  })
                }else if(this.userid == '下级用户') {
                  this.userlist = res.data.datas.erji
                  if(this.userlist.length == 0) {
                    this.withoutjl = true
                  }
                  uni.setNavigationBarTitle({
                    title:'下级用户'
                  })
                }else if(this.userid == '佣金明细') {
                  uni.setNavigationBarTitle({
                    title:'佣金明细'
                  })
                  this.estimate = false
                  this.getbrokerage()
                }else if(this.userid == '推广订单') {
                  uni.setNavigationBarTitle({
                    title:'推广订单'
                  })
                  this.promotion()
                }
              
        			return;   
        		} else { 
        			uni.showToast({
        				title: res['data']['msg'],
        				icon: 'none'
        			});
              
        		}
        	},
        	fail: () => {},
        	complete: () => {
        	}
        });
      },
      getbrokerage() {
        uni.request({
        	url: getApp().globalData.apiDomain+'/wallet/listDetail',
        	method: 'POST',
        	header: {
        		'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
        		'token': uni.getStorageSync('wbyun_token'),
            'wbapp':'weixin_mp_xbgy'
        	},
        	data: {
            'type':'rebate'
          },
        	dataType: 'json',
        	success:  res => {
            console.log(res);
        		if (res['data']['code'] == 200) {
               this.yjlist = res.data.datas
        			return;   
        		} else { 
        			uni.showToast({
        				title: res['data']['msg'],
        				icon: 'none'
        			});
        		}
        	},
        	fail: () => {},
        	complete: () => {
        	}
        });
      },
      promotion(){
        uni.request({
        	url: getApp().globalData.apiDomain+'/invite/order',
        	method: 'POST',
        	header: {
        		'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
        		'token': uni.getStorageSync('wbyun_token'),
            'wbapp':'weixin_mp_xbgy'
        	},
        	data: {
            'type':'rebate'
          },
        	dataType: 'json',
        	success:  res => {
            console.log(res);
        		if (res['data']['code'] == 200) {
               this.userlist = res.data.datas
               console.log(this.userlist);
               if(this.userlist== undefined) {
                 this.withoutjl = true
               }
        			return;   
        		} else { 
        			uni.showToast({
        				title: res['data']['msg'],
        				icon: 'none'
        			});
        		}
        	},
        	fail: () => {},
        	complete: () => {
        	}
        });
      }
    }
  }
</script>

<style>
  .box {
    display: flex;
    justify-content: space-between;
    padding: 5rpx 20rpx;
    margin: 5rpx;
    background-color: #fff;
  }
  .headerimg-box {
    width: 90rpx;
    height: 90rpx;
    background-color: rgb(241,241,241);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 20rpx;
    border-radius: 10rpx;
  }
  .headerimg {
    width: 50rpx;
    height: 50rpx;
   
  }
  .header-box {
    display: flex;
    align-items: center;
    
  }
  .without {
    width: 100%;
    text-align: center;
    margin-top: 300rpx;
    font-size: 40rpx;
    color: #c2c2c2;
  }
  .recordimg{
    width: 150rpx;
    height: 150rpx;
  }
</style>